package etr.bk.gui;

import etr.bk.gui.rpan.*;
import etr.bk.gui.lpan.*;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.imageio.ImageIO;

public class PictureFromfFile
{
	private InputStream inpStream;
	private BufferedImage img;

	// singletone ?????????
	
	
	public PictureFromfFile(File fil)
	{
		try
		{
			if (fil != null)
			{
				this.inpStream = new BufferedInputStream(new FileInputStream(fil));
			}
			else
			{
				this.inpStream = null;
			}
		}
		catch (FileNotFoundException e)
		{
			System.out.println("IO Exception File not Found");
			e.getMessage();
		}
	}

	public BufferedImage getImageFromFile()
	{
		if (this.inpStream != null)
		{
			try
			{
				this.img = ImageIO.read(this.inpStream);
			}
			catch (IOException e)
			{
				System.out.println("Error in getImageFromFile");
				e.printStackTrace();
			}

			return this.img;
		}
		else
		{
			return null;
		}
	}

}
